#include <stdio.h>

#define DEBUG 1

#if DEBUG
#define NAME_LEN 25

#define MAX_PARTS 100

struct part {
int number;
char name[NAME_LEN+1];
int on_hand;
};


int read_line(char str[], int n);
int find_part(int number, const struct part inv[], int np);
void insert(struct part inv[], int *np);
void search(const struct part inv[], int np);
void update(struct part inv[], int np);
void print(const struct part inv[], int np);
#else
#include"lab51.h"
#endif
int main()
{
    struct part {
        int number;
        char name[NAME_LEN + 1];
        int on_hand;
    } inventory[MAX_PARTS];
 
    int number_parts = 0;
    char code;
    for (;;) {
        printf("Enter operation code:");
        scanf("%c", &code);
        while (getchar() != '\n')
            ;
        switch (code) {
        case 'i':
            insert(inventory, &number_parts);
            break;
        case 's':
            search(inventory, number_parts);
            break;
        case 'u':
            update(inventory, number_parts);
            break;
        case 'p':
            print(inventory, number_parts);
            break;
        case 'q':
            return 0;
        default:
            printf("Illegal code\n");
        }
        printf("\n");
    }

    return 0;
}
int find_part(int number, const struct part inv[], int np) 
{
    
}
void insert(struct part invet[],int *num) {
    if(*num==MAX_PARTS)
    {
        printf("Database is full; can't add more parts.\n");
        return;  
    }
    int part_number;
    scanf(" %d",&part_number);
    if(find_part(part_number,invet,*num)>=0) 
    {
        printf("Part already exists.\n");
        return;
    }
    int now = *num;
    now++;
    *num = now;
    invet[now].number = part_number;
    
}